<?php
class EmptyAction extends BaseAction
{
    private $_ACTION_NAME = ACTION_NAME;
    private $_MODULE_NAME = MODULE_NAME;

    public function _initialize()
    {
        parent::_initialize();
    }

    /**
     * 默认方法
     * @author Ice <iceinto@mallog.com.cn>
     */
    public function _empty()
    {
        $pathInfo = $this->getUrlPathInfo();
        if (method_exists($this, $this->_ACTION_NAME)) {
            $this->$this->_ACTION_NAME;
        } else {
            if ($pathInfo) {
                $pathSize = count($pathInfo);
                $data = array();
                if ($pathSize == 2) {
                    //商场
                    $data = $this->checkUrl($pathInfo[1]);
                    //调用商场首页
                    if ($data['level'] == 1) {
                        A('Home/Mall')->home($data['mall']);
                    }
                } else if ($pathSize == 3) {
                    //楼层
                    $data = $this->checkUrl($pathInfo[1], $pathInfo[2]);
                    if ($data['level'] == 2) {
                        A('Home/Mall')->floor($data['mall'], $data['floor']);
                    }
                } else if ($pathSize == 4) {
                    //品牌
                    $data = $this->checkUrl($pathInfo[1], $pathInfo[2], $pathInfo[3]);
                    if ($data['level'] == 3) {
                        A('Home/FloorBrand')->home($data['mall'], $data['floor'], $data['brand']);
                    }
                } else {
                    exit;
                }

            } else {
                exit();
            }
        }
    }

    /**
     * 获取访问URL
     * @author Ice <iceinto@mallog.com.cn>
     */
    public function getUrlPathInfo()
    {
        $pathInfo = strtolower($_SERVER['PATH_INFO']);
        $pathInfo = explode(C('URL_PATHINFO_DEPR'), $pathInfo);
        return $pathInfo;
    }

    /**
     * 联系商场
     * @author Ice <iceinto@mallog.com.cn>
     */
    public function about()
    {
        $pathInfo = $this->getUrlPathInfo();
        $data = $this->checkUrl($pathInfo[1]);
        A('Home/Mall')->about($data['mall']);
    }

    /**
     * 商场楼层信息
     * @author Ice <iceinto@mallog.com.cn>
     */
    public function floors(){
        $pathInfo = $this->getUrlPathInfo();
        $data = $this->checkUrl($pathInfo[1]);
        A('Home/Mall')->floors($data['mall']);
    }

    /**
     * 商场特卖
     * @author Ice <iceinto@mallog.com.cn>
     */
    public function discount(){
        $pathInfo = $this->getUrlPathInfo();
        $data = $this->checkUrl($pathInfo[1]);
        A('Home/Mall')->discount($data['mall']);
    }
}

?>